import { BaseEntity } from "../../base/entity/base";
import { Column, Entity } from "typeorm";

export enum ProductType {
    /**
     * 包车
     */
    CAR = 'car',
    /**
     * 导游
     */
    GUIDE = 'guide',
    /**
     * 代驾
     */
    DRIVER = 'driver',
    /**
     * 普通商品
     */
    GOODS = 'goods',

}

export enum ProductStatus {

    /**
     * 草稿
     */
    DRAFT = 0,
    /**
     * 上架
     */
    ON_SALE = 1,
    /**
     * 下架
     */
    OFF_SALE = 2,
    /**
     * 删除
     */
    DELETE = 3,
}

@Entity('product_info', { comment: '产品信息' })
export class ProductInfoEntity extends BaseEntity {

    @Column({
        type: 'varchar',
        length: 255,
        comment: '产品名称',
    })
    name: string;

    @Column({
        type: 'varchar',
        length: 255,
        comment: '产品封面',
    })
    cover: string;

    @Column({
        type: 'varchar',
        length: 255,
        comment: '产品详情',
    })
    content: string; // 产品详情

    @Column({
        type: 'decimal',
        precision: 10,
        scale: 2,
        nullable: false,
        comment: '产品价格',
    })
    basePrice: number;

    @Column({
        type: 'json',
        comment: '产品规格',
    })
    specs: {
        name: string;
        value: string[];
    }[];


    @Column({
        type: 'varchar',
        length: 255,
        comment: '产品图片',
    })
    images: string[];

    @Column({
        type: 'varchar',
        length: 255,
        comment: '产品类型',
    })
    type: string;

    @Column({
        type: 'varchar',
        length: 255,
        comment: '来源',
    })
    source: 'system' | 'user' | 'storage' | 'other';

    @Column({
        nullable: true,
        comment: '发布到云仓的ID',
    })
    publishedStorageId?: number;

    @Column({
        nullable: true,
        comment: '来源云仓的ID',
    })
    sourceStorageId?: number;


    @Column({
        comment: '分类ID',
    })
    categoryId: number;

    @Column({
        nullable: true,
        comment: '来源产品ID',
    })
    sourceProductId?: number

    @Column({
        type: 'enum',
        enum: ProductStatus,
        default: ProductStatus.ON_SALE,
        comment: '状态',
    })
    status: ProductStatus

}